package cn.iocoder.yudao.module.resource.service.advertiser;

import cn.iocoder.yudao.module.resource.dal.dataobject.advertiser.ResourceAdvertiserDO;
import cn.iocoder.yudao.module.resource.dal.mysql.advertiser.ResourceAdvertiserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 广告商 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
@Slf4j
public class ResourceAdvertiserServiceImpl implements ResourceAdvertiserService {

    @Resource
    private ResourceAdvertiserMapper advertiserMapper;

    @Override
    public Long createAdvertiser(ResourceAdvertiserDO advertiserDO) {
        advertiserMapper.insert(advertiserDO);
        return advertiserDO.getId();
    }

    @Override
    public void updateAdvertiser(ResourceAdvertiserDO advertiserDO) {
        advertiserMapper.updateById(advertiserDO);
    }

    @Override
    public void deleteAdvertiser(Long id) {
        advertiserMapper.deleteById(id);
    }

    @Override
    public ResourceAdvertiserDO getAdvertiser(Long id) {
        return advertiserMapper.selectById(id);
    }

    @Override
    public ResourceAdvertiserDO getAdvertiserByUserId(Long userId) {
        return advertiserMapper.selectByUserId(userId);
    }

    @Override
    public List<ResourceAdvertiserDO> getAdvertiserList() {
        return advertiserMapper.selectList();
    }

}
